package com.crm.service.salPlan;

import com.crm.pojo.SalPlan;
import com.crm.repository.SalPlanRepository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SalPlanServiceImpl implements SalPlanService {
    @Resource
    private SalPlanRepository salPlanRepository;

    @Override
    public List<SalPlan> findSalPlansByChcId(Long plaChcId) throws Exception {
        return salPlanRepository.findSalPlansByPlaChcId(plaChcId);
    }

    @Override
    public int delSalPlanByPlaChcId(Long plaChcId) throws Exception {
        return salPlanRepository.deleteSalPlanByPlaChcId(plaChcId);
    }

    @Override
    public int editSalPlanInPlaTodoByPlaId(String plaTodo, Long plaId) throws Exception {
        return salPlanRepository.editSalPlanByPlaId(plaTodo, plaId);
    }

    public SalPlan addSlaPlan(SalPlan salPlan) throws Exception {
        return salPlanRepository.save(salPlan);
    }

    @Override
    public void delSalPlanByPlaId(Long plaId) throws Exception {
        salPlanRepository.deleteById(plaId);
    }

    @Override
    public int editSalPlanInPlaResultByPlaId(String plaResult, Long plaId) throws Exception {
        return salPlanRepository.editSalPlanInPlaResultByPlaId(plaResult, plaId);
    }

    @Override
    public int findSalPlanByPlaChcIdIsNull(Long plaChcId) throws Exception {
        return salPlanRepository.findSalPlanByPlaChcIdIsNull(plaChcId);
    }
}